{{!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
}}

<div class="editor-overlay settings-container fadeIn">
  <div class='settings-controls'>
    <button class="btn btn-success btn-xs" {{action 'add'}}><i class="fa fa-plus"></i> Add</button>

    {{#if settings.length}}
      <button class="btn btn-danger btn-xs" {{action 'removeAll'}}><i class="fa fa-minus"></i> Remove All</button>
    {{/if}}

    <button class="btn btn-success btn-xs pull-right" {{action 'saveDefaultSettings'}}><i class="fa fa-plus"></i> Save Default Settings</button>
  </div>

  {{#each setting in settings}}
    <div class="setting col-md-12 col-sm-12">
      <form>
        <div class="form-group">
          <div class="input-group">
            <div class="input-group-addon">
              {{typeahead-widget
                  options=predefinedSettings
                  excluded=excluded
                  optionLabelPath="name"
                  optionValuePath="name"
                  selection=setting.key
                  create="addKey"
              }}
            </div>
            <div {{bind-attr class=":input-group-addon setting.valid::has-error"}}>

              <div class="setting-input-value">
                {{#if setting.key.values}}
                  {{select-widget items=setting.key.values
                                  labelPath="value"
                                  selectedValue=setting.selection
                                  defaultLabelTranslation="placeholders.select.value"
                  }}
                {{else}}
                  {{input class="input-sm form-control" placeholderTranslation="placeholders.select.value" value=setting.selection.value}}
                {{/if}}
              </div>

              <span class="fa fa-times-circle remove pull-right" {{action 'remove' setting}}></span>
            </div>
          </div>
        </div>
      </form>
    </div>
  {{/each}}
</div>
